package com.kl.feign;

import com.kl.domain.CarDTO;
import com.kl.em.Result;
import com.kl.feign.fallback.CarServiceFeignFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@FeignClient(value = "kunlun-car-service-b",fallback = CarServiceFeignFallback.class)//服务名找项目
public interface CarServiceFeign {

    //车辆 管理 接口

    //根据车辆ID进行查询
    @GetMapping("/car/selectCarById/{id}")
//    @GetMapping("selectCarById/{id}")
    public Result<CarDTO> selectCarById(@PathVariable Long id);

    //增加车辆
    @PostMapping("/car/insertCar")
    public Result insertCar(@RequestBody CarDTO carDTO);


    //修改车辆信息(修改车辆状态)
    //name="carDTO",value = "车辆实体类",required = false,
    //name="state",value = "车辆状态更新(当前状态1:空闲,2:运行中,3维修保养,4报废,)",required = false,
    //name="id",value = "车辆ID",必须传
    @PutMapping("/car/updateCar/{id}")
    Result updateCar(@RequestBody CarDTO carDTO ,@PathVariable Long id
            ,@RequestParam(required = false) String state);

    //删除车辆信息(逻辑删除)
    @DeleteMapping("/car/deleteCar")
    Result deleteCar(@RequestBody Long[] id);

    //车辆模糊查询分页
    /*      name="pageNumber",value = "起始页数",required = false
            name="pageSize",value = "每页条数",required = false
            name="carType",value = "车的类型",required = false
            name="site",value = "所属站点",required = false
            name="state",value = "当前状态",required = false
            name="carDriver",value = "车辆司机",required = false*/
    @GetMapping("/car/selectCarLikePage")
    Result<Map<String,Object>> selectCarLikePage(@RequestParam(defaultValue = "1")Integer pageNumber
            , @RequestParam(defaultValue = "3")Integer pageSize
            , @RequestParam(required = false)Integer carType
            , @RequestParam(required = false)String site
            , @RequestParam(required = false)String state
            , @RequestParam(required = false)String carDriver);

    //批量修改车辆状态 ( state 当前状态1:空闲,2:运行中,3维修保养,4报废,)'
    @PutMapping("/car/updateCarBatchState")
    Result updateCarBatchState(@RequestBody Long[] id,@RequestParam Integer state);

    @GetMapping("/car/toStateCar")
    Result<List<CarDTO>> getBylogitIdToList(@RequestParam Long id);

    @PutMapping("/car/updateByid")
    Result getBylogitIdUpdate(@RequestBody CarDTO dto);
}
